<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%	
String sysUserId = request.getParameter("sysUserId");
request.setAttribute("sysUserId",sysUserId); 
%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style>
	body,html{
		margin: 0 auto;
		height:100%;
		width:100%;
	}
</style>
</head>
<body>
	<div class="divfrist" id="system_UserAdd" style="width:100%;height:100%;">
						<div style="width:100%;height:0.7%;overflow:hidden;"></div>
						<div style="width:100%;height:98.6%;">
								<div style="width:0.4%;height:100%;float:left;overflow:hidden;"></div>
								<div style="width:99.2%;height:100%;float:left;">
									 <div class="allborder" style="overflow: auto;height:100%;max-height:100%;">
													<!--内容区 -->
										<div style="padding:10px 0 10px 60px">
										    <form id="system_addUserff" method="post">
										    	<input type="hidden" name="sysUserId"  id="sysUserId" ></input>
										    	<table>									    	
										    		<tr>
										    			<td>用户登陆名:</td>
										    			<td><input type="text" name="sysUserName"  id="sysUserName" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户姓名:</td>
										    			<td><input type="text" name="sysUserRealyName"  id="sysUserRealyName" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户密码:</td>
										    			<td><input type="text" name="sysUserPwd"  id="sysUserPwd" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>密码确认:</td>
										    			<td><input type="text" name="sysUserPwd1"  id="sysUserPwd1" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户电话:</td>
										    			<td><input type="text" name="sysUserTell"  id="sysUserTell" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户工号:</td>
										    			<td><input type="text" name="sysUserNumber"  id="sysUserNumber" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户邮件:</td>
										    			<td><input type="text" name="sysUserEmail"  id="sysUserEmail" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户身份证号码:</td>
										    			<td><input type="text" name="sysUserSelfID"  id="sysUserSelfID" ></input></td>
										    		</tr>
										    		<tr>
										    			<td>用户状态:</td>
										    			<td>
										    			<select class="easyui-combobox"  id="sysUserState" name="sysUserState" style="height:30px;" data-options="panelWidth:100,panelHeight:'auto'">
										    				<option value="1">启用</option>
										    				<option value="0">禁用</option>
										    			</select>
										    			</td>
										    		</tr>
										    	</table>
										    </form>
										    </div>
										    <div style="text-align:center;padding:5px">
										    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-ok" onclick="window.addUser.addUser()">提交</a>
										    	<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="window.addUser.clear()">清空</a>
										    </div>	
													<!--内容区 -->
									 </div>
								</div>
								<div class="width:0.37%;height:100%;float:left;overflow:hidden;"></div>
						</div>
						<div class="width:100%;height:0.6%;overflow:hidden;"></div>
	</div>
</body>
<script type="text/javascript">
(function(){
	//设定所有文本验证方法
	function validateInput(){
		var valuetype=["length[3,15]","unnormal"];
		$('#sysUserName').validatebox({   
		    required: true,   
		    validType: ["unnormal","length[3,15]"] 
		});
		$('#sysUserRealyName').validatebox({   
		    required: true,   
		    validType:  ["unnormal","length[3,15]"]  
		}); 
		$('#sysUserPwd').validatebox({   
		    required: true,   
		    validType:  ["unnormal","length[6,15]"]  
		}); 
		$('#sysUserPwd1').validatebox({   
		    required: true,   
		    validType:  ["unnormal","length[6,15]",'same["sysUserPwd"]']  
		}); 
		$('#sysUserState').validatebox({   
		    required: true
		 
		}); 
		$('#sysUserTell').validatebox({   
		    required: true,   
		    validType: ["unnormal","length[6,15]"]   
		}); 
		$('#sysUserNumber').validatebox({   
		    required: true,   
		    validType: ["unnormal","length[1,15]"]   
		}); 
		$('#sysUserSelfID').validatebox({   
		    required: true,   
		    validType: ["unnormal","length[6,20]"]   
		}); 
		$('#sysUserEmail').validatebox({   
		    required: true,   
		    validType: ["email"] 
		}); 
		
	}
	//增加角色
	function addUser(){
		$.messager.progress({
			title:'请注意',
			text:'数据正在加载.....'
		});
		$('#system_addUserff').form('submit', {
				url: "${pageContext.request.contextPath}/sys/sysUserAction!addUser.action",
				onSubmit: function(){
				var isValid = $(this).form('validate');
				if (!isValid){
					$.messager.progress('close');	// 当form不合法的时候隐藏工具条
				}
				return isValid;	// 返回false将停止form提交 
			},
			success: function(data){
				$.messager.progress('close');
				if(data=="success"){
					alert("增加用户成功");
					
				}else if(data=="same"){
					alert("已经有相同名称的用户或者工号存在");
				}else if(data=="us"){
					alert("更新成功");
				}else{
					alert("操作失败");
				}
				// 当成功提交之后隐藏进度条
			}
		});			
	}
	function clear(){
		var id =$("#sysUserId").val();
		$('#system_addUserff').form('clear');
		$("#sysUserId").val(id);
	}
	//注册所有事件
	window["addUser"]={};
	window["addUser"]["addUser"]=addUser;
	window["addUser"]["clear"]=clear;
	$(function(){	
		//easyUi注册
		$.parser.parse("#system_UserAdd"); 
		//增加验证
		validateInput();
		//是不是更新
		if("${sysUserId}"!=null&&"${sysUserId}"!=""){
			//加载修改数据
			$.ajax({
			   type: "POST",
			   async:false,
			   url: "${pageContext.request.contextPath}/sys/sysUserAction!getUserOne.action",
			   data:{sysUserId:"${sysUserId}"},
			   dataType:'json',
			   success: function(msg){	
				   $('#system_addUserff').form('load',msg);
			   },
			   error:function(a,b,c){
				   alert("查询用户失败");
				}
			});
		}
	});	
	
})();
</script>
</html>